package com.wxzz.elearing.user.api.server;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.user.dto.AdminQueAnsEnterpriseDto;
import com.wxzz.elearing.user.dto.EnterpriseDto;
import com.wxzz.elearing.user.entity.Enterprise;
import com.wxzz.elearing.user.service.IEnterpriseImproveService;
import com.wxzz.elearing.user.service.IEnterpriseService;
import com.wxzz.elearning.common.dto.FeignEnterpriseDto;
import com.wxzz.elearning.common.vo.JgPageVo;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/enterprise-api")
public class EnterpriseApi {

    @Autowired
    private IEnterpriseService enterpriseService;

    @RequestMapping(value = "selectEnterpriseById", method = RequestMethod.POST)
    public ReturnVO<String> selectEnterpriseById(@RequestParam("enterpriseId") Long enterpriseId) {
        return enterpriseService.selectEnterpriseById(enterpriseId);
    }

    @RequestMapping(value = "listEnterprise", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<JSONObject>>> selectEnterList(@RequestBody AdminQueAnsEnterpriseDto adminQueAnsEnterpriseDto) {
        return enterpriseService.enterList(adminQueAnsEnterpriseDto);
    }

    @RequestMapping(value = "selectAllEnterprise", method = RequestMethod.POST)
    public List<Long> selectAllEnterprise() {
        return enterpriseService.selectAllEnterprise();
    }

    /**
     * 根据企业id查询企业详情
     *
     * @param enterpriseId
     * @return
     */
    @RequestMapping(value = "selectEnterpriseDtoById/{enterpriseId}", method = RequestMethod.POST)
    public FeignEnterpriseDto selectEnterpriseDtoById(@PathVariable Long enterpriseId) {
        return enterpriseService.selectEnterpriseDtoById(enterpriseId);
    }

    /**
     * 修改企业的星级
     * @param enterpriseId
     * @param star
     */
    @RequestMapping(value = "updateEnterpriseStart/{enterpriseId}/{star}", method = RequestMethod.POST)
    public void updateEnterpriseStart(@PathVariable Long enterpriseId, @PathVariable Integer star) {
        enterpriseService.updateEnterpriseStart(enterpriseId, star);
    }

    @Autowired
    private IEnterpriseImproveService enterpriseImproveService;

    /**
     * 查询改提案
     *
     * @param wxUserId
     * @return
     */
    @RequestMapping(value = "selectWxUserCenterImprove/{wxUserId}", method = RequestMethod.POST)
    public Integer selectWxUserCenterImprove(@PathVariable Long wxUserId) {
        return enterpriseImproveService.selectWxUserCenterImprove(wxUserId);
    }
}
